<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.zust.java.bean.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品</title>
<script type="text/javascript">
    function buy(name) {
    	var num = prompt("您需要多少", 1);
    	
    	window.location.href='insertOrderDetail?num=' + num +'&name=' + name;
    }
</script>
</head>
<body>
<%
    List<Product> list = (List<Product>) request.getSession().getAttribute("product");
%>
<table border="1px" style="text-align:center">
    <tr>
        <th>ID</th>
        <th>名称</th>
        <th>价格</th>
        <th>描述</th>
        <th>操作</th>
    </tr>
    <%
        for (Product p : list) {
    %>
    <tr>
        <td><%= p.getId() %></td>
        <td name="name"><%= p.getName() %></td>
        <td><%= p.getPrice() %></td>
        <td><%= p.getDescription() %></td>
        <td>
            <button name="buy" onclick="buy('<%= p.getName() %>')">购买</button>
        </td>
    </tr>
    <% } %>
</table>
</body>
</html>